package com.jucai.pppeiyouclient.adapter;

import android.support.v7.widget.RecyclerView;
import android.util.SparseArray;
import android.view.View;


/**
 * Created by UPC on 2017/3/30.
 */

public class CommonHolder extends RecyclerView.ViewHolder {
    public View view;
    private SparseArray<View> viewSparseArray;

    public CommonHolder(View itemView) {
        super(itemView);
        view=itemView;
        viewSparseArray=new SparseArray<>();
    }

    /**
     * 获取view
     *
     * @param viewId
     * @param <T>
     * @return
     */
    public <T extends View> T getView(int viewId) {
        View view = viewSparseArray.get(viewId);
        if (view == null) {
            view = itemView.findViewById(viewId);
            viewSparseArray.put(viewId, view);
        }
        return (T) view;
    }

}
